package com.rick.demo.mywebsocket.server;

import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.rick.demo.mywebsocket.entities.Dealer;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@Slf4j
public class TreadTaskServer {

    @Async
    @Scheduled(cron = "0 0 */1 * * ?")
    public List<Dealer> requestAll4s(Map<String,String> headers){
        List<Dealer> dealers;
        String url = "http://autopre.openspeech.cn/carservice/v2.0/maintain/shop/getProvincesAndCities";
        String param = JSONUtil.toJsonStr(headers);
        String body = HttpRequest.post(url).headerMap(headers, true).execute().body();

        //String post = HttpUtil.post(url, param);
        Object data = JSONUtil.parseObj(body).get("data");

        dealers = null;
        log.info("所有省市数据：{}",dealers);
        return dealers;
    }






}
